#include <iostream>
using std::cout;
using std::endl;

class Point
{
public:
    Point(int x,int y)
    : _ix(x)
    , _iy(y)
    {
        /* cout << "Point(int,int)" << endl; */
    }

    ~Point(){
        /* cout << "~Point()" << endl; */
    }

    void print(){
        cout << "(" << _ix
            << "," << _iy;
            /* << ")"; */
    }
protected:
    int _ix;
private:
    int _iy;
};

class Point3D
: private Point
{
public:
    Point3D(int x,int y,int z)
    : Point(x,y)//显式调用基类的构造函数，初始化基类子对象
    , _iz(z)
    {
        /* cout << "Point3D(int * 3)" << endl; */
    }
    
    void display(){
        //通过基类子对象访问_ix
        cout << _ix << endl;
        /* cout << _iy << endl; */

        //print在Point3D这一层成为了private属性
        print();
        cout << "," << _iz << ")" << endl;  
    }

    ~Point3D(){
        /* cout << "~Point3D()" << endl; */
    }

private:
    int _iz;
};

class Point4D
: public Point3D
{
    void func(){
        print();
    }
};

void test0(){
    //从内存的角度上
    //创建一个派生类对象，其内存布局中
    //会存在一个完整的基类对象（基类子对象）
    cout << sizeof(Point3D) << endl;
    Point3D pt3d1(1,2,3);
    pt3d1.display();

    /* pt3d1.print();//error */
    /* pt3d1._ix;//error */
    /* pt3d1._iy;//error */
}

int main(void){
    test0();
    return 0;
}
